<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增直播间')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-zbj-add">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">标题：</label>
                    <div class="col-sm-8">
                        <input name="biaoti" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">简介：</label>
                    <div class="col-sm-8">
                        <input name="jianjei" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">开始时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="startTime" class="form-control" placeholder="yyyy-MM-dd-hh-mm" type="text">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">结束时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="endTime" class="form-control" placeholder="yyyy-MM-dd-hh-mm" type="text">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">主播图片：</label>
                    <div class="col-sm-8">
                        <input type="hidden" name="zcrTp">
                        <div class="file-loading">
                            <input class="form-control file-upload" id="zcrTp" name="file" type="file">
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">主播名字：</label>
                    <div class="col-sm-8">
                        <input name="zcrName" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">分类：</label>
                    <div class="col-sm-8">
                        <select name="fl" class="form-control" th:with="type=${@dict.getType('zbj_type')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">状态：</label>
                    <div class="col-sm-8">
                        <select name="zt" class="form-control" required>
                            <option value="" disabled selected>请选择状态</option>
                            <option value="下线">下线</option>
                            <option value="在线">在线</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">上传视频：</label>
                    <div class="col-sm-8">
                        <input type="hidden" name="videoUrl">
                        <div class="file-loading">
                            <input class="form-control file-upload" id="videoUpload" name="video" type="file" accept="video/*">
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">标签：</label>
                    <div class="col-sm-8">
                        <input name="bq" class="form-control" type="text">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">        var prefix = ctx + "system/zbj"
    $("#form-zbj-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-zbj-add').serialize());
        }
    }

    $("input[name='startTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='endTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $(".file-upload").fileinput({
        uploadUrl: ctx + 'common/upload',
        maxFileCount: 1,
        autoReplace: true
    }).on('fileuploaded', function (event, data, previewId, index) {
        $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
    }).on('fileremoved', function (event, id, index) {
        $("input[name='" + event.currentTarget.id + "']").val('')
    });

    $(".file-upload#videoUpload").fileinput({
        uploadUrl: ctx + 'common/uploadVideo',
        maxFileCount: 1,
        autoReplace: true,
        allowedFileExtensions: ['mp4', 'avi', 'mov']
    }).on('fileuploaded', function (event, data, previewId, index) {
        $("input[name='videoUrl']").val(data.response.url);
    }).on('fileremoved', function (event, id, index) {
        $("input[name='videoUrl']").val('');
    });
    </script>
</body>
</html>